import React, { Component } from 'react'
import './index.css'

export default class Item extends Component {
	updateTodo = (id,event) => {
		this.props.updateTodo(id,event.target.checked)
	}
	delTodo = (id) => {
		return (event) => {
			this.props.delTodo(id)
		}
	}
    render() {
		const {id,name,done} = this.props
        return (
            <li>
				<label>
					<input type="checkbox" checked={done} onChange={event => this.updateTodo(id,event)}/>
					<span>{name}</span>
				</label>
				<button className="btn btn-danger" onClick={this.delTodo(id)}>删除</button>
			</li>
        )
    }
}
